package vo;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

@Entity
@NamedQueries({ 
	@NamedQuery(name = "Sentence.findAll", query = "select e from Sentence e order by created_at"),
	@NamedQuery(name = "Sentence.findByType", query = "select e from Sentence e where sentenceType.id=? order by created_at"),
	@NamedQuery(name = "Sentence.findByTypeKeyword", query = "select e from Sentence e where sentenceType.id=? and text like ? order by created_at"),
	@NamedQuery(name = "Sentence.findByKeyword", query = "select e from Sentence e where text like ? order by created_at"),
	@NamedQuery(name = "Sentence.findTotalCount", query = "select count(*) from Sentence e order by created_at"),
	@NamedQuery(name = "Sentence.findByPaperId", query = "select e from Sentence e where paper.id=? order by created_at"),
	@NamedQuery(name = "Sentence.findTotalCountByPaperId", query = "select count(*) from Sentence e where paper.id=? order by created_at"),
	@NamedQuery(name = "Sentence.findTotalCountByType", query = "select count(*) from Sentence e where sentenceType.id=? order by created_at"),
	@NamedQuery(name = "Sentence.findTotalCountByKeyword", query = "select count(*) from Sentence e where text like ? order by created_at"),
	@NamedQuery(name = "Sentence.findTotalCountByTypeKeyword", query = "select count(*) from Sentence e where sentenceType.id=? and text like ? order by created_at"),
	}
)
@Table(name = "sentence")
public class Sentence extends BaseEntity {

	@JoinColumn(name = "paper_id")
	@ManyToOne(fetch = FetchType.LAZY)
	private Paper paper;

	@JoinColumn(name = "type")
	@ManyToOne(fetch = FetchType.LAZY)
	private SentenceType sentenceType;

	@Column(name = "text")
	private String text;

	@Column(name = "created_at")
	private String createdAt;

	public Paper getPaper() {
		return paper;
	}

	public void setPaper(Paper paper) {
		this.paper = paper;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public SentenceType getSentenceType() {
		return sentenceType;
	}

	public void setSentenceType(SentenceType sentenceType) {
		this.sentenceType = sentenceType;
	}

	public String getCreatedAt() {
		return createdAt;
	}

	public void setCreatedAt(String createdAt) {
		this.createdAt = createdAt;
	}


}
